package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourLike;
import com.ruoyi.system.service.ITourLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 点赞管理Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/like")
public class TourLikeController extends BaseController
{
    @Autowired
    private ITourLikeService tourLikeService;

    /**
     * 查询点赞管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:like:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourLike tourLike)
    {
        startPage();
        List<TourLike> list = tourLikeService.selectTourLikeList(tourLike);
        return getDataTable(list);
    }

    /**
     * 导出点赞管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:like:export')")
    @Log(title = "点赞管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourLike tourLike)
    {
        List<TourLike> list = tourLikeService.selectTourLikeList(tourLike);
        ExcelUtil<TourLike> util = new ExcelUtil<TourLike>(TourLike.class);
        return util.exportExcel(list, "like");
    }

    /**
     * 获取点赞管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:like:query')")
    @GetMapping(value = "/{likeId}")
    public AjaxResult getInfo(@PathVariable("likeId") Long likeId)
    {
        return AjaxResult.success(tourLikeService.selectTourLikeById(likeId));
    }

    /**
     * 新增点赞管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:like:add')")
    @Log(title = "点赞管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourLike tourLike)
    {
        return toAjax(tourLikeService.insertTourLike(tourLike));
    }

    /**
     * 修改点赞管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:like:edit')")
    @Log(title = "点赞管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourLike tourLike)
    {
        return toAjax(tourLikeService.updateTourLike(tourLike));
    }

    /**
     * 删除点赞管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:like:remove')")
    @Log(title = "点赞管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{likeIds}")
    public AjaxResult remove(@PathVariable Long[] likeIds)
    {
        return toAjax(tourLikeService.deleteTourLikeByIds(likeIds));
    }
}
